package com.hhkj.study.admin.user.controller;

import com.hhkj.study.admin.user.entity.UserWechatCompany;
import com.hhkj.study.admin.user.model.req.UserWechatCompanyReq;
import com.hhkj.study.admin.user.model.res.UserWechatCompanyRes;
import com.hhkj.study.admin.user.service.biz.UserWechatCompanyBizService;
import com.ruoyi.common.annotation.PermissionPrefix;
import com.ruoyi.common.base.biz.controller.v3.BaseController;
import com.ruoyi.common.enums.RRExceptionCodeEnum;
import com.ruoyi.common.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* UserWechatCompanyController
*
* @author SERVER
* @since 2024-09-06
*/
@Slf4j
@RestController
@PermissionPrefix("user:userWechatCompany")
@RequestMapping("/admin/customer/user/wechat/company")
public class UserWechatCompanyController extends BaseController<UserWechatCompany, UserWechatCompanyReq, UserWechatCompanyRes, UserWechatCompanyBizService> {

    @PreAuthorize("@ss.hasPermi(this, ':export')")
    @PostMapping("/export")
    public void export(@RequestBody UserWechatCompanyReq req, HttpServletResponse response) {
        try {
            getBizService().export(req, response);
        } catch (GlobalException e) {
            throw new GlobalException(e.getMessage());
        } catch (Exception e) {
            log.error("导出文件失败", e);
            throw new GlobalException("系统异常，文件导出失败，请稍后重试");
        }
    }
}
